# Generated by Django 2.2.9 on 2020-03-05 12:56

import django.core.validators
import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("orga", "0006_auto_20170831_1201"),
        ("challenge", "0056_invoice_permissions"),
    ]

    operations = [
        migrations.CreateModel(
            name="Invoice",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "generated_at",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "status",
                    models.IntegerField(
                        choices=[(0, "Brouillon"), (1, "Validée")], default=0
                    ),
                ),
                (
                    "ref",
                    models.CharField(
                        max_length=20, unique=True, verbose_name="Référence"
                    ),
                ),
                (
                    "title",
                    models.CharField(blank=True, max_length=255, verbose_name="Titre"),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="invoices",
                        to="orga.Organization",
                        verbose_name="Établissement",
                    ),
                ),
                (
                    "season",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="challenge.Season",
                        verbose_name="Saison",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="InvoiceLine",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("nb_bikes", models.PositiveSmallIntegerField()),
                ("nb_participants", models.PositiveSmallIntegerField()),
                (
                    "cost_bikes",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=8,
                        validators=[django.core.validators.MinValueValidator(0)],
                    ),
                ),
                (
                    "cost_participants",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=8,
                        validators=[django.core.validators.MinValueValidator(0)],
                    ),
                ),
                (
                    "invoice",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="lines",
                        to="challenge.Invoice",
                    ),
                ),
                (
                    "session",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="challenge.Session",
                    ),
                ),
            ],
            options={
                "unique_together": {("session", "invoice")},
            },
        ),
    ]
